<include file="Public/header" />
<include file="Public/menu" />
<link rel="stylesheet" href="/Public/admin/adminlte/bootstrap/css/bootstrap-switch.min.css">
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            店铺配置
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 店铺配置</a></li>
            <li class="active">物流公司</li>
        </ol>
    </section>

    <!-- 内容 -->
    <section class="content"><div class="row"><div class="col-md-12"><div class="box">

        <!-- /.box-header -->
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover">
                <tbody>
                <tr>
                    <th width="2%"></th>
                    <th width="3%">ID</th>
                    <th>物流公司</th>
                </tr>
                <volist name="wlist" id="item">
                    <tr>
                       <td><input type="checkbox" class="grid-item"  data-id="{$item['corp_id']}" data-name="{$item['name']}" <if condition="$item['isSelect'] eq 1 ">checked</if> ></td>
                        <td>{$i}</td>
                        <td>{$item['name']}</td>
                    </tr>
                </volist>
                </tbody>
            </table>
        </div>
        <div class="box-footer clearfix">
            <input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;
            <a class="btn btn-sm btn-info add-goods">保存</a>
        </div>

        <!-- /.box-body -->
    </div></div></div>

    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer" />
<script src="__PUBLIC__/admin/adminlte/bootstrap/js/bootstrap-switch.min.js"></script>

<script>
    $(function () {

        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });


        $('.add-goods').on('click', function () {
            var selected = [];
            $('.grid-item').each(function () {
                var id = $(this).data('id');
                if ($(this).is(':checked')) {
                    var goods_values = id ;

                    selected.push([goods_values,$(this).data('name')]);
                }
            });

            if (selected.length == 0) {
                alert('请选择物流公司');return;
            }


            $.ajax({
                type:'post',
                data:{data: selected},
                url:'/admin/Dlycorp/save',
                success:function (data) {
                    if(data.status==1){
                        alert(data.msg);
                    }else{
                        alert(data.msg);
                    }
                },
                error:function () {
                    alert('参数错误');
                }
            })

        })










    });
</script>